<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增账户')" />
	<th:block th:include="include :: select2-css" />
</head>
<body>
<div class="main-content">
	<form class="form-horizontal m" id="form-account-add">
		<!--<input name="deptId" type="hidden" id="treeId"/>-->
		<h4 class="form-header h4">基本信息</h4>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label is-required">账户类型：</label>
					<div class="col-sm-8">
						<select name="accountType" class="form-control m-b" th:with="type=${@dict.getType('finance_account_class')}">
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
						</select>
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label is-required">账户编码：</label>
					<div class="col-sm-8">
						<input name="accountNo" placeholder="请输入账户编码（账号）" class="form-control" type="text" maxlength="30" required>
					</div>
				</div>
			</div>
		</div>

		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label is-required">账户余额：</label>
					<div class="col-sm-8">
						<input name="accountBalance" placeholder="请输入余额（当前余额/可用额度）" class="form-control"
							   type="text" maxlength="30" required>
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label is-required">授权额度：</label>
					<div class="col-sm-8">
						<input name="initialQuota" placeholder="请输入初始额度/授权额度" class="form-control" type="text" maxlength="30" required>
					</div>
				</div>
			</div>
		</div>
		<!---->
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label is-required">开户日期：</label>
					<div class="col-sm-8">
						<input class="time-input" name="establishDate" type="text" id="establishDate" placeholder="开户时间" />
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label is-required">有效日期：</label>
					<div class="col-sm-8">
						<input class="time-input" name="expiryTime" type="text" id="expiryTime" placeholder="到期时间(有效期)" />
					</div>
				</div>
			</div>
		</div>
		<!---->
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label is-required">授权方：</label>
					<div class="col-sm-8">
						<input name="licensor" placeholder="请输入授权方（发卡行/运营商ISP）" class="form-control" type="text" maxlength="30" required>
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">账户状态：</label>
					<div class="col-sm-8">
						<label class="toggle-switch switch-solid">
							<input type="checkbox" id="status" checked>
							<span></span>
						</label>
					</div>
				</div>
			</div>
		</div>

		<!-- 其他信息(备注)-->
		<h4 class="form-header h4">其他信息</h4>
		<div class="row">
			<div class="col-sm-12">
				<div class="form-group">
					<label class="col-xs-2 control-label">备注：</label>
					<div class="col-xs-10">
						<textarea name="remark" maxlength="1024" class="form-control" rows="3"></textarea>
					</div>
				</div>
			</div>
		</div>
	</form>
</div>

<div class="row">
	<div class="col-sm-offset-5 col-sm-10">
		<button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
		<button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
	</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script>
	var prefix = ctx + "finance/account";

	$("#form-account-add").validate({
		onkeyup: false,
		rules:{
			menuType:{
				required:true,
			},
			menuName:{
				remote: {
					url: prefix + "/checkAccountUnique",
					type: "post",
					dataType: "json",
					data: {
						"accountNo": function() {
							return $("accountNo").val();
						}
					},
					dataFilter: function(data, type) {
						return $.validate.unique(data);
					}
				}
			}
		},
		messages: {
			"accountNo": {
				remote: "账户信息已经存在"
			}
		},
		focusCleanup: true
	});

	<!-- 新增表单提交 -->``
	function submitHandler() {
		/*if ($.validate.form() ) {
			var data = $("#form-account-add").serialize();
			var status = $("#status").is(':checked') == true ? 1 : 0;
			data.push({"name": "status", "value": status});
			$.operate.save(prefix + "/add", data);
		}*/
		var accountType = $("#accountType").val();
		var accountNo = $("#accountNo").val();
		var accountBalance = $("#accountBalance").val();
		var initialQuota = $("#initialQuota").val();
		var establishDate = $("#establishDate").val();
		var expiryTime = $("#expiryTime").val();
		var licensor = $("#licensor").val();
		var status = $("#status").is(':checked') == true ? 1 : 0;
		var remark = $("#remark").val();

		debugger
		var data = $("#form-account-add").serialize();
		$.operate.save(prefix + "/add", data);
	}

</script>
</body>
</html>